package at.jaki.ubb.crawling.demo.core;

import java.util.ArrayList;
import java.util.List;

import at.jaki.ubb.crawling.demo.dataFinder.KeplerWebfinder;
import at.jaki.ubb.crawling.demo.dataTransformer.KeplerTransformer;
import at.jaki.ubb.crawling.demo.db.Facade;
import at.jaki.ubb.crawling.demo.interpreter.InterpreterMain;
import at.jaki.ubb.crawling.model.config.CrawlingEngineConfig;
import at.jaki.ubb.crawling.model.config.DataFinderConfig;
import at.jaki.ubb.crawling.model.config.DataFinderManagerConfig;
import at.jaki.ubb.crawling.model.config.DataTransformerConfig;
import at.jaki.ubb.crawling.model.config.DataTransformerManagerConfig;

public class ConfigGenerator {

	private ConfigGenerator() {
	}

	static CrawlingEngineConfig getConfig() {
		CrawlingEngineConfig cec = new CrawlingEngineConfig();
		cec.setDataFinderManagerConfig(getDataFinderManagerConfig());
		cec.setDataTransformerManagerConfig(getDataTransformerManagerConfig());
		cec.setDbFacadeClass(Facade.class.getCanonicalName());
		cec.setDataInterpreterClass(InterpreterMain.class.getCanonicalName());
		return cec;
	}

	private static DataTransformerManagerConfig getDataTransformerManagerConfig() {
		DataTransformerManagerConfig c = new DataTransformerManagerConfig();
		List<DataTransformerConfig> dataTransformers = new ArrayList<DataTransformerConfig>(1);
		dataTransformers.add(getKeplerTransformer());
		c.setDataTransformers(dataTransformers);
		return c;
	}

	private static DataTransformerConfig getKeplerTransformer() {
		DataTransformerConfig dtc = new DataTransformerConfig();
		dtc.setClazzName(KeplerTransformer.class.getCanonicalName());
		dtc.setLogName("kepler transformer");
		return dtc;
	}

	private static DataFinderManagerConfig getDataFinderManagerConfig() {
		DataFinderManagerConfig c = new DataFinderManagerConfig();
		List<DataFinderConfig> dataFinders = new ArrayList<DataFinderConfig>(1);
		dataFinders.add(getKeplerWebMiner());
		c.setDataFinders(dataFinders);
		return c;
	}

	private static DataFinderConfig getKeplerWebMiner() {
		DataFinderConfig dfc = new DataFinderConfig();
		dfc.setClazzName(KeplerWebfinder.class.getCanonicalName());
		dfc.setLogName("kepler web miner");
		return dfc;
	}
}
